package com.example.owner.lettery1.modlus

import android.app.Dialog
import android.app.ProgressDialog
import android.os.Bundle
import android.support.v4.app.DialogFragment

class ProgressDialogFragment : DialogFragment(){

    private var msg: String? = null
    private var isCancel= false
    private var cancelOutside = false

    companion object {
        fun newInstance(msg: String,
                        isCancel: Boolean, cancelOutside: Boolean): ProgressDialogFragment {
            val dialog = ProgressDialogFragment()
            val args = Bundle()
            args.putString("msg", msg)
            args.putBoolean("cancelable", isCancel)
            args.putBoolean("cancelOutside", cancelOutside)
            dialog.arguments = args
            return dialog
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        msg = arguments!!.getString("msg")
        isCancel = arguments!!.getBoolean("cancelable")
        cancelOutside = arguments!!.getBoolean("cancelOutside")
        //		int style = DialogFragment.STYLE_NORMAL, theme=;
        //		setStyle(style, theme);
    }

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {

        val mProgressDialog = ProgressDialog(activity)
        //        mProgressDialog.setIconAttribute(android.R.attr.alertDialogIcon);
        //        mProgressDialog.setTitle(R.string.select_dialog);
        //        mProgressDialog.setTitle(title);
        mProgressDialog.setMessage(msg)
        //		mProgressDialog.setIndeterminateDrawable(
        //				getResources().getDrawable(R.drawable.loading_animation));
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER)
        mProgressDialog.setCanceledOnTouchOutside(cancelOutside)
        isCancelable = isCancel
        return mProgressDialog
    }

}